Skip to content

Instantly share code, notes, and snippets.

@pwxcoo
pwxcoo / huffman.cpp
Created July 14, 2019 13:56
huffman encoding implemented by c++
#include <iostream>
#include <string>
#include <queue>
#include <unordered_map>
using namespace std;
// A Tree node
struct Node
{
char ch;
@JacobFV
JacobFV / dont_raise_until_done.py
Created May 17, 2024 18:44
Collect all the errors in a block of code before raising
import traceback
class DontRaiseUntilDone:
def __init__(self):
self.exceptions = []
def __enter__(self):
return self
def __exit__(self, exc_type, exc_val, exc_tb):
@wojteklu
wojteklu / clean_code.md
Last active May 17, 2024 18:42
Summary of 'Clean code' by Robert C. Martin

Code is clean if it can be understood easily – by everyone on the team. Clean code can be read and enhanced by a developer other than its original author. With understandability comes readability, changeability, extensibility and maintainability.


General rules

  1. Follow standard conventions.
  2. Keep it simple stupid. Simpler is always better. Reduce complexity as much as possible.
  3. Boy scout rule. Leave the campground cleaner than you found it.
  4. Always find root cause. Always look for the root cause of a problem.

Design rules

@diego3g
diego3g / settings.json
Last active May 17, 2024 18:36
VSCode Settings (Updated)
{
"workbench.startupEditor": "newUntitledFile",
"editor.fontSize": 14,
"editor.lineHeight": 1.8,
"javascript.suggest.autoImports": true,
"javascript.updateImportsOnFileMove.enabled": "always",
"editor.rulers": [80, 120],
"extensions.ignoreRecommendations": true,
"typescript.tsserver.log": "off",
"files.associations": {
@Klerith
Klerith / random-hex.md
Created September 22, 2023 17:47
Secure Random Hex

Comando con Ruby instalado

ruby -rsecurerandom -e 'puts SecureRandom.hex(20)'

Ejemplo: No usar en producción

4510c8cf2fe423f8be5afccbdd30c678677e172b

@minhphuc429
minhphuc429 / hash.mqh
Created March 28, 2020 22:24
Libraries: JSON Parser MQL4
// $Id: hash.mqh 125 2014-03-03 08:38:32Z ydrol $
#ifndef YDROL_HASH_MQH
#define YDROL_HASH_MQH
//#property strict
/*
This is losely ported from a C version I have which was in turn modified from hashtable.c by Christopher Clark.
Copyright (C) 2014, Andrew Lord (NICKNAME=lordy) <forex@NICKNAME.org.uk>
Copyright (C) 2002, 2004 Christopher Clark <firstname.lastname@cl.cam.ac.uk>
@simonw
simonw / recover_source_code.md
Last active May 17, 2024 18:28
How to recover lost Python source code if it's still resident in-memory

How to recover lost Python source code if it's still resident in-memory

I screwed up using git ("git checkout --" on the wrong file) and managed to delete the code I had just written... but it was still running in a process in a docker container. Here's how I got it back, using https://pypi.python.org/pypi/pyrasite/ and https://pypi.python.org/pypi/uncompyle6

Attach a shell to the docker container

Install GDB (needed by pyrasite)

apt-get update && apt-get install gdb
@0xdevalias
0xdevalias / converting-json-to-openapi-swagger-spec.md
Created June 2, 2023 01:09
Exploring tools that allow converting a JSON response automagically into an OpenAPI / Swagger spec.

Converting JSON to OpenAPI / Swagger spec

Exploring tools that allow converting a JSON response automagically into an OpenAPI / Swagger spec.

Test JSON Response

{
    "accounts": {
        "default": {